<template>
    <div>
      <header-tilte :title="title"></header-tilte>
      <div class="flex_center">
        <div class="bodyContent">
          <loading v-if="showLoading"></loading>
          <div class="shopC_div flex flex_between" v-for="(shop,index) in shopList" v-if="!showLoading">
            <div class="shopC_img">
              <img style="border-radius: 20px" src="./img/my_bg.png" v-if="shop.shop_logo == undefined || shop.shop_logo == null || shop.shop_logo == ''">
              <img :src="shop.shop_logo" v-if="shop.shop_logo != undefined && shop.shop_logo != null && shop.shop_logo != ''">
            </div>
            <div class=" shopC_content flex flex_column flex_around">
              <p style="font-weight: bold">{{shop.shop_name}}</p>
              <p style="font-size: 0.7rem;color: #777">{{shop.area_info +' '+ shop.address}}</p>
            </div>
            <mu-flex justify-content="center" align-items="center" class="shopC_radio" >
              <mu-radio style="margin-left: 16px" v-model="shop.is_default" value="1" label="" @click="changeRadio(shop,index)"></mu-radio>
            </mu-flex>
          </div>
        </div>
      </div>
    </div>
</template>

<script>
    import HeaderTilte from "../../components/headerTilte";
    import Loading from "../../components/loading";

    export default {
      data(){
        return{
          showLoading:true,
          title:'店铺切换',
          shopList:[]
        }
      },
      mounted(){
        this.checkLogin();
        this.initShopList();
      },
      methods:{
        initShopList(){
          this.yesS.getShopList(
            this.$comParams()
          ).then(res => {
            var status = res.status;
            if(status == 1){

              this.shopList = res.data.shop_list;
              for(var i=0;i<this.shopList.length;i++){
                this.shopList[i].is_default = this.shopList[i].is_default +'';
              }
            }
            this.showLoading = false;
          })
        },
        changeRadio(obj,index){
          for(var i=0;i<this.shopList.length;i++){
            this.shopList[i].is_default = '0';
          }
          var _slef = this;
          obj.is_default = '1';
          this.yesS.changeShopDefualt(
            this.$combineParams({new_sid:obj.id})
          ).then(res => {
            console.log(res)
            _slef.$router.push({path:'/qds/mall'});
          })
        }
      },
      components: {
        Loading,
        HeaderTilte},
      name: "shop-change"
    }
</script>

<style scoped>
  @import "css/shopChange.css";
  /*@import 'http://cdn.bootcss.com/material-design-icons/3.0.1/iconfont/material-icons.css';*/
</style>
